// // // // // // // // // kkkkKCreturnStorage: function () {
let _this = this;
const LApp = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
   AllocInfo: {},
   myDate: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var AllocInfo = {};
   if (options.code != undefined) {
    let code = [options.code];
    if (code) {
      AllocInfo.Codes = code;
      AllocInfo.Num = code.length;
      AllocInfo.ProductID = options.ProductId;
      AllocInfo.FromWarehouseId = options.FromWarehouseId;
    }
   } else {
     AllocInfo.Codes = null;
     AllocInfo.Num = 0;
     AllocInfo.ProductID = 0;
    AllocInfo.FromWarehouseId=0;
   }
   this.setData({
     AllocInfo: AllocInfo
   })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var pages = getCurrentPages();
    var currPage = pages[pages.length - 1];
    if (this.data.myDate == 1) {
      this.setData({
        AllocInfo: {}
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  //click 继续扫码
  continueOper: function () {
   let that = this;
   wx.scanCode({
    success: (res) => {
      var codes = that.data.AllocInfo.Codes;
      if (codes){
        if (codes.indexOf(res.result) > -1) {
          wx.showToast({
            title: "该码已重复扫描",
          })
          return
        }
      }
      if (!that.data.AllocInfo.ProductID) { that.data.AllocInfo.ProductID=0;}
     LApp._get({
       url: 'nbapi/fleedtool/db/check',
       data: { code: res.result, userId: LApp.globalData.userInfo.UserID, proId: that.data.AllocInfo.ProductID },
      success: function (r) {
       if (r) {
        if (codes == null) codes = [];
        codes.push(res.result);
        var AllocInfo = {};
        AllocInfo.Codes = codes;
        AllocInfo.Num = AllocInfo.Codes.length;
        AllocInfo.ProductID = r.ProductId;
        AllocInfo.FromWarehouseId = r.FromWarehouseId;
        that.setData({
          AllocInfo: AllocInfo
        })
       }
       else {
        wx.showToast({
         title: r,
        })
       }
      }
     })

    }
   })
  },
  //click relation Info
  gounBoxing: function () {
    let _this = this;
   // _this.data.AllocInfo.FormCode = "DB" + new Date().getTime();
        //页面传值并跳转
        if (_this.data.AllocInfo) {
          LApp.pages.add(_this);
          wx.navigateTo({
            url: '../unBoxing',
          })
        } 
  }
  // gounBoxing: function () {
  //  let _this = this;
  //  LApp._get({
  //   url: "nbapi/fleedtool/getinfo/formcode",
  //   data: { formType: 'DB', enterpriseId: LApp.globalData.userInfo.EnterpriseId },
  //   success: function (res) {
  //     _this.data.AllocInfo.FormCode = res;
  //    //页面传值并跳转
  //     if (_this.data.AllocInfo) {
  //     LApp.pages.add(_this);
  //     wx.navigateTo({
  //       url: '../unBoxing',
  //     })
  //    }
  //   }
  //  })
  // }
})